
package com.android.matmanual;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.view.MotionEvent;
import android.view.View;

public class Drawl extends View{
	 private int mov_x;
	 private int mov_y;
	 private Paint paint;
	 private Canvas canvas;
	 private Bitmap bitmap;
	 private int blcolor;
	 public Drawl(Context context) {
	 super(context);
	  paint=new Paint(Paint.DITHER_FLAG);
	  bitmap = Bitmap.createBitmap(480, 854, Bitmap.Config.ARGB_8888); 
	  canvas=new Canvas();
	  canvas.setBitmap(bitmap);
	  
	  paint.setStyle(Style.STROKE);
	  paint.setStrokeWidth(5);
	  paint.setColor(Color.RED);
	  paint.setAntiAlias(true);
	   
	 }
	 @Override
	 protected void onDraw(Canvas canvas) 
	 {
		 canvas.drawBitmap(bitmap,0,0,null);
	 }
	 @Override
	 public boolean onTouchEvent(MotionEvent event) 
	 {
		  if (event.getAction() == MotionEvent.ACTION_MOVE) 
		  {
		   canvas.drawLine(mov_x, mov_y, event.getX(), event.getY(), paint);
		   invalidate();
		  }
		  if (event.getAction() == MotionEvent.ACTION_DOWN) {
			Touch_Test.mPassButton.setVisibility(View.INVISIBLE);
			Touch_Test.mFailButton.setVisibility(View.INVISIBLE);
		   mov_x=(int) event.getX();
		   mov_y=(int) event.getY();
		   canvas.drawPoint(mov_x, mov_y, paint);
		   invalidate();
		  }
		  if(event.getAction()==MotionEvent.ACTION_UP)
		  {
			Touch_Test.mPassButton.setVisibility(View.VISIBLE);
			Touch_Test.mFailButton.setVisibility(View.VISIBLE);
			  canvas.drawColor(Color.BLACK);
			  invalidate();
		  }
		  mov_x=(int) event.getX();
		  mov_y=(int) event.getY();
		  return true;
	 } 
}



		 